******************************************************************
* Varieties of Economic Vulnerability  				 			 *
* Melina Altamirano, Sarah Berens & Franziska Deeg 	 			 *
* March 2021         											 *
* Main Analysis (Weights)										 *
******************************************************************

use MEX_survey_RF_Vulnerabilities_AltamiranoEtAl2021.dta, clear 

***Control variables***

global xvar_1  age age_sq female   c.resp_edu inc_amain dependants  i.urban  i.state
global xvar_2  age age_sq female   c.resp_edu inc_amain dependants  i.urban  i.state corr_perception 
global xvar_3    age age_sq female  c.resp_edu inc_amain i.urban i.state  job_insecurity union_memb 
global xvar_4  age age_sq female   c.resp_edu inc_amain dependants  i.urban  i.state i.vote_choice		
global xvar_5 age age_sq female   c.resp_edu inc_amain dependants  i.urban  i.state CCT_receive				
		

*********** 
* Main: Define weights and ordered probit analysis Labor Market Status; Table 1 in Manuscript
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b1.light_formalv2 $xvar_1
estimates store M2a
svy: oprobit pension b2.labor_force3   $xvar_1
estimates store M2b
svy: oprobit health b1.light_formalv2 $xvar_1
estimates store M3a
svy: oprobit health b2.labor_force3  $xvar_1
estimates store M3b
svy: oprobit prospera b1.light_formalv2 $xvar_1
estimates store M5a
svy: oprobit prospera b2.labor_force3  $xvar_1
estimates store M5b
svy: oprobit prog_tax b1.light_formalv2 $xvar_1
estimates store M6a
svy: oprobit prog_tax b2.labor_force3   $xvar_1
estimates store M6b

	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M* using Tables/Table1.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Social Policy Preferences and Labor Market Dualization")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")	
	
 
*********** 
* Robustness: ordered probit analysis Labor Market Status with corr_perception control
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b1.light_formalv2 $xvar_2
estimates store M2a
svy: oprobit pension b2.labor_force3   $xvar_2
estimates store M2b
svy: oprobit health b1.light_formalv2 $xvar_2
estimates store M3a
svy: oprobit health b2.labor_force3  $xvar_2
estimates store M3b
svy: oprobit prospera b1.light_formalv2 $xvar_2
estimates store M5a
svy: oprobit prospera b2.labor_force3  $xvar_2
estimates store M5b
svy: oprobit prog_tax b1.light_formalv2 $xvar_2
estimates store M6a
svy: oprobit prog_tax b2.labor_force3   $xvar_2
estimates store M6b

	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M* using Tables/TableF_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Social Policy Preferences and Labor Market Dualization, Additional Control: Corruption Perception")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")
	
*********** 
* Robustness: ordered logit regression with vote choice as control
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b1.light_formalv2 $xvar_4
estimates store M2a
svy: oprobit pension b2.labor_force3   $xvar_4
estimates store M2b
svy: oprobit health b1.light_formalv2 $xvar_4
estimates store M3a
svy: oprobit health b2.labor_force3  $xvar_4
estimates store M3b
svy: oprobit prospera b1.light_formalv2 $xvar_4
estimates store M5a
svy: oprobit prospera b2.labor_force3  $xvar_4
estimates store M5b
svy: oprobit prog_tax b1.light_formalv2 $xvar_4
estimates store M6a
svy: oprobit prog_tax b2.labor_force3   $xvar_4
estimates store M6b

	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M* using Tables/TableI_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered probit regression: Social Policy Preferences and Labor Market Dualization, Additional Control: Vote Choice")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors. PQMex Survey 2018.")	
	
*********** 
* Robustness: ordered logit regression with CCT received as control
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b1.light_formalv2 $xvar_5
estimates store M2a
svy: oprobit pension b2.labor_force3   $xvar_5
estimates store M2b
svy: oprobit health b1.light_formalv2 $xvar_5
estimates store M3a
svy: oprobit health b2.labor_force3  $xvar_5
estimates store M3b
svy: oprobit prospera b1.light_formalv2 $xvar_5
estimates store M5a
svy: oprobit prospera b2.labor_force3  $xvar_5
estimates store M5b
svy: oprobit prog_tax b1.light_formalv2 $xvar_5
estimates store M6a
svy: oprobit prog_tax b2.labor_force3   $xvar_5
estimates store M6b

	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M* using Tables/TableH_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered probit regression: Social Policy Preferences and Labor Market Dualization, Additional Control: CCT Received")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors. PQMex Survey 2018.")	
			

*********** 
* Robustness: ordered logit regression with different variable for labor force -> formal, informal, unemployed
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b2.labor_force   $xvar_1
estimates store M2b
svy: oprobit health b2.labor_force  $xvar_1
estimates store M3b
svy: oprobit prospera b2.labor_force  $xvar_1
estimates store M5b
svy: oprobit prog_tax b2.labor_force   $xvar_1
estimates store M6b

	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M* using Tables/TableD_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Social Policy Preferences and Labor Market Dualization Disaggregated")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")		
	

*********** 
* Main: ordered logit regression with Labor Market Perspective 
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension fortoinf $xvar_1
estimates store M1
svy: oprobit pension inftofor $xvar_1
estimates store M2
svy: oprobit health fortoinf $xvar_1
estimates store M3
svy:oprobit health inftofor $xvar_1
estimates store M4
svy: oprobit prospera fortoinf $xvar_1
estimates store M5
svy: oprobit prospera inftofor $xvar_1
estimates store M6
svy: oprobit prog_tax fortoinf $xvar_1
estimates store M7
svy: oprobit prog_tax inftofor $xvar_1
estimates store M8


	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	
	esttab M*  using Tables/TableC_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Future Employment Prospects")       ///
	nonumbers mtitles ("(M1)" "(M2)" "(M3)" "(M4)" "(M5)" "(M6)" "(M7)" "(M8) " )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")
	
*********** 
* Robustness: ordered logit regression with Labor Market Perspective with vote choice as control
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension fortoinf $xvar_4
estimates store M1
svy: oprobit pension inftofor $xvar_4
estimates store M2
svy: oprobit health fortoinf $xvar_4
estimates store M3
svy: oprobit health inftofor $xvar_4
estimates store M4
svy: oprobit prospera fortoinf $xvar_4
estimates store M5
svy: oprobit prospera inftofor $xvar_4
estimates store M6
svy: oprobit prog_tax fortoinf $xvar_4
estimates store M7
svy: oprobit prog_tax inftofor $xvar_4
estimates store M8


	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	
	esttab M*  using Tables/TableJ_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered probit regression: Social Policy Preferences and Labor Market Dualization: Future Employment; Additional Control: Vote Choice")       ///
	nonumbers mtitles ("(M1)" "(M2)" "(M3)" "(M4)" "(M5)" "(M6)" "(M7)" "(M8) " )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")	
	
	
*********** 
* Main: Household constellation differentiating between mixed HH, formal resp, and mixed HH, informal resp
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b2.household4 $xvar_1
estimates store M1

svy: oprobit health b2.household4 $xvar_1
estimates store M2

svy: oprobit prospera b2.household4 $xvar_1
estimates store M3

svy: oprobit prog_tax b2.household4 $xvar_1
estimates store M4


	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M1 M2 M3 M4 using Tables/TableB_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Household Composition")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")	
	
*********** 
* Robustness: Household constellation, differentiating between mixed HH, formal resp, and mixed HH, informal resp, controlled for vote choice
***********
estimates clear
svyset [pw=pondfin]

svy: oprobit pension b2.household4 $xvar_4
estimates store M1

svy: oprobit health b2.household4 $xvar_4
estimates store M2

svy: oprobit prospera b2.household4 $xvar_4
estimates store M3

svy: oprobit prog_tax b2.household4 $xvar_4
estimates store M4


	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M1 M2 M3 M4 using Tables/TableK_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered probit regression: Social Policy Preferences and Labor Market Dualization: Household Constellation, Additional Control: Vote Choice")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")		
	
************+
* Create Main Figure: coefficients plot
*************
svyset [pw=pondfin]

estimates clear
svy: oprobit pension b1.light_formalv2 $xvar_1
estimates store M1
svy: oprobit pension b2.labor_force3   $xvar_1
estimates store M2
svy: oprobit health b1.light_formalv2 $xvar_1
estimates store M3
svy: oprobit health b2.labor_force3  $xvar_1
estimates store M4
svy: oprobit prospera b1.light_formalv2 $xvar_1
estimates store M5
svy: oprobit prospera b2.labor_force3  $xvar_1
estimates store M6
svy: oprobit prog_tax b1.light_formalv2 $xvar_1
estimates store M7
svy: oprobit prog_tax b2.labor_force3   $xvar_1
estimates store M8

svy: oprobit pension b2.household4 $xvar_1
estimates store M9
svy: oprobit health b2.household4 $xvar_1
estimates store M10
svy: oprobit prospera b2.household4 $xvar_1
estimates store M11
svy: oprobit prog_tax b2.household4 $xvar_1
estimates store M12

svy: oprobit pension fortoinf $xvar_1
estimates store M13
svy: oprobit pension inftofor $xvar_1
estimates store M14
svy: oprobit health fortoinf $xvar_1
estimates store M15
svy: oprobit health inftofor $xvar_1
estimates store M16
svy: oprobit prospera fortoinf $xvar_1
estimates store M17
svy: oprobit prospera inftofor $xvar_1
estimates store M18
svy: oprobit prog_tax fortoinf $xvar_1
estimates store M19
svy: oprobit prog_tax inftofor $xvar_1
estimates store M20

 coefplot (M1, label(Tab 1: Workers) mlcolor(black) mfcolor(black)) (M2, label(Tab 1: All)) (M9, label(Tab B: Households)  mfcolor(white)) (M13, label(Tab C: Formal to {bf:Informal})) (M14, label(Tab C: Informal to {bf:Formal})), bylabel(Pensions) ///
	   || (M3) (M4) (M10)  (M15) (M16)        , bylabel(Health Care)  ///
	   || (M5) (M6)  (M11)  (M17) (M18)      , bylabel(Prospera)  ///
	   || (M7) (M8)  (M12)  (M19) (M20)     , bylabel(Prog. Tax)  ///
       ||, drop( _cons age age_sq female resp_edu inc_amain dependants 1.urban 0.urban 1.state 0.state) xline(0) xlabel(-0.8(0.2)1) xtitle("{bf: Ordered Probit Coefficients}") 
	   *xlabel(-2(1)2)
	   *byopts(xrescale) mfcolor(magenta*.3)
graph save Figures/Figure3.gph, replace
graph export Figures/Figure3.pdf, as(pdf) replace	


*********
* Table Appendix: Labor market history  
*********
estimates clear
svyset [pw=pondfin]

svy: oprobit  pension secure_lmhistory $xvar_1
estimates store M2a

svy: oprobit  health secure_lmhistory $xvar_1
estimates store M3a

svy: oprobit  prospera secure_lmhistory $xvar_1
estimates store M5a

svy: oprobit  prog_tax secure_lmhistory $xvar_1
estimates store M6a
	

		esttab  M2a  M3a  M5a M6a  using Tables/TableE_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Social Policy Preferences and Labor Market Dualization: History")       ///
	nonumbers mtitles ("(1 )" "(2 )" "(3 )" "(4 )" "(5 )" "(6 )" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")
	
*********** 
* Robustness: ordered probit Labor Market Status and controls for job insecurity and union membership
***********
estimates clear
svyset [pw=pondfin]

estimates clear
svy: oprobit pension b1.light_formalv2 $xvar_3
estimates store M2a
svy: oprobit health b1.light_formalv2 $xvar_3
estimates store M3a
svy: oprobit prospera b1.light_formalv2 $xvar_3
estimates store M5a
svy: oprobit prog_tax b1.light_formalv2 $xvar_3
estimates store M6a


	est tab M*, star(.1 .05 .01) stat(N ll aic bic chi2) 
	

	esttab M* using Tables/TableG_Appendix.tex, replace cells(b (star fmt(3)) se(par fmt(3))) starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) label  se bic                               /// 
	title("Ordered Probit Regression: Additional Controls: Job Insecurity and Union Membership")       ///
	nonumbers mtitles ("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)" "(8)" "(9)" "(10)" )  ///
	addnote("+ p<0.10, * p<0.05, ** p<0.01, *** p<0.001. Note: The numbers in parentheses are standard errors; all models include survey weights. PQMex Survey 2018.")
	
	
************+
* Figure A Appendix: coefficient plots robust clustered standard errors for municipality
*************
estimates clear
oprobit pension b1.light_formalv2 $xvar_1, vce(cluster mpio)
estimates store M1
oprobit pension b2.labor_force3   $xvar_1, vce(cluster mpio)
estimates store M2
oprobit health b1.light_formalv2 $xvar_1, vce(cluster mpio)
estimates store M3
oprobit health b2.labor_force3  $xvar_1, vce(cluster mpio)
estimates store M4
oprobit prospera b1.light_formalv2 $xvar_1, vce(cluster mpio)
estimates store M5
oprobit prospera b2.labor_force3  $xvar_1, vce(cluster mpio)
estimates store M6
oprobit prog_tax b1.light_formalv2 $xvar_1, vce(cluster mpio)
estimates store M7
oprobit prog_tax b2.labor_force3   $xvar_1, vce(cluster mpio)
estimates store M8

oprobit pension b2.household4 $xvar_1, vce(cluster mpio)
estimates store M9
oprobit health b2.household4 $xvar_1, vce(cluster mpio)
estimates store M10
oprobit prospera b2.household4 $xvar_1, vce(cluster mpio)
estimates store M11
oprobit prog_tax b2.household4 $xvar_1, vce(cluster mpio)
estimates store M12

oprobit pension fortoinf $xvar_1, vce(cluster mpio)
estimates store M13
oprobit pension inftofor $xvar_1, vce(cluster mpio)
estimates store M14
oprobit health fortoinf $xvar_1, vce(cluster mpio)
estimates store M15
oprobit health inftofor $xvar_1, vce(cluster mpio)
estimates store M16
oprobit prospera fortoinf $xvar_1, vce(cluster mpio)
estimates store M17
oprobit prospera inftofor $xvar_1, vce(cluster mpio)
estimates store M18
oprobit prog_tax fortoinf $xvar_1, vce(cluster mpio)
estimates store M19
oprobit prog_tax inftofor $xvar_1, vce(cluster mpio)
estimates store M20

 coefplot (M1, label(Workers) mlcolor(black) mfcolor(black)) (M2, label(All)) (M9, label(Households)  mfcolor(white)) (M13, label(Formal to {bf:Informal})) (M14, label(Informal to {bf:Formal})), bylabel(Pensions) ///
	   || (M3) (M4) (M10)  (M15) (M16)        , bylabel(Health Care)  ///
	   || (M5) (M6)  (M11)  (M17) (M18)      , bylabel(Prospera)  ///
	   || (M7) (M8)  (M12)  (M19) (M20)     , bylabel(Prog. Tax)  ///
       ||, drop( _cons age age_sq female resp_edu inc_amain dependants 1.urban 0.urban 1.state 0.state) xline(0) xlabel(-0.8(0.2)1) xtitle("{bf: Ordered Probit Coefficients}") 
	   *xlabel(-2(1)2)
	   *byopts(xrescale) mfcolor(magenta*.3)
graph save Figures/FigureA_Appendix.gph, replace
graph export Figures/FigureA_Appendix.pdf, as(pdf) replace